﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Web
{
    public static class Certify
    {
        public static User user
        {
            get { return HttpContext.Current.Session["certify"] as User; }
            set { HttpContext.Current.Session["certify"] = value; }
        }

        public static string regsid
        {
            get { return HttpContext.Current.Session["regsid"] as string; }
            set { HttpContext.Current.Session["regsid"] = value; }
        }

        public static bool guest
        {
            get { return user == null; }
            private set { }
        }

        public static bool god
        {
            get
            {
                var usr = user;
                if (usr != null) return usr.god;
                return false;
            }
            private set { }
        }

        public static string username
        {
            get
            {
                var usr = user;
                if (usr != null) return usr.username;
                return "";
            }
            private set { }
        }

        public class User
        {
            public bool success = true;
            public string username, nickname, email, motto, sid, name, school;
            public int sex;
            public string birthday;
            public bool publicPersonalInfo, admin, god, teacher;
        }

        public static bool teacherUp
        {
            get
            {
                var usr = user;
                if (usr != null) return usr.god || usr.teacher;
                return false;
            }
            private set { }
        }
    }
}
